﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BLO
{
    /// <summary>
    /// Summary description for Message
    /// </summary>
    public class Message
    {
        DTO.Message info;
        DAO.Message messageDAO;

        public Message()
        {
            this.messageDAO = new DAO.Message();
            this.info = new DTO.Message();
        }

           /// <summary>
        /// Message Information.
        /// </summary>
        public DTO.Message Info
        {
            get { return this.info; }
            set { this.info = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ID"></param>
        public static Message GetMessage(String ID)
        {
            DAO.Message messageDAO = new DAO.Message();
            Message message = new  Message();
            message.Info = messageDAO.GetMessage(ID);
            return message;
        }

        /// <summary>
        /// Insert Message information to database.
        /// </summary>
        public int Insert()
        {
            return messageDAO.InsertMessage(this.info);
        }

        /// <summary>
        /// Update information to database.
        /// </summary>
        public int Update()
        {
            return messageDAO.UpdateMessage(this.info);
        }

        /// <summary>
        /// Re-get all information from database about this Messages.
        /// </summary>
        public void Refresh()
        {
            this.info = messageDAO.GetMessage(this.info.ID.ToString());
        }

        /// <summary>
        /// Delete this news from database.
        /// </summary>
        public int Delete()
        {
            return messageDAO.DeleteMessage(this.info);
        }
    }
}